-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete useless loop in TransportBulkAction$BulkOperation.doRun() #16950
base: main
Are you sure you want to change the base?
Delete useless loop in TransportBulkAction$BulkOperation.doRun() #16950
Conversation
Signed-off-by: kkewwei <[email protected]> Signed-off-by: kkewwei <[email protected]>
9f29f7c
to
0e48cc9
Compare
❕ Gradle check result for 0e48cc9: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16950 +/- ##
============================================
+ Coverage 72.21% 72.26% +0.04%
- Complexity 65232 65304 +72
============================================
Files 5299 5299
Lines 303496 303491 -5
Branches 43931 43929 -2
============================================
+ Hits 219181 219325 +144
+ Misses 66302 66156 -146
+ Partials 18013 18010 -3 ☔ View full report in Codecov by Sentry. |
org.opensearch.cluster.MinimumClusterManagerNodesIT.testThreeNodesNoClusterManagerBlock #14289 |
.indexShards(clusterState, concreteIndex.getName(), docWriteRequest.id(), docWriteRequest.routing()) | ||
.shardId(); | ||
List<BulkItemRequest> shardRequests = requestsByShard.computeIfAbsent(shardId, shard -> new ArrayList<>()); | ||
shardRequests.add(new BulkItemRequest(i, docWriteRequest)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two conditions above that skip the doc before getting here:
if (addFailureIfRequiresAliasAndAliasIsMissing(docWriteRequest, i, metadata)) {
continue;
}
if (addFailureIfIndexIsUnavailable(docWriteRequest, i, concreteIndices, metadata)) {
continue;
}
Those conditions are not present in the loop below. On the surface this looks like a logical difference. Is this a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrross For most indexing, these two conditions are not fulfilled. Merely creating a new loop for the sole purpose of calculating the shardId appears to be rather pointless.
Description
The second loop is useless, we can merge it into the first loop. The exist it/ut can cover the changed, I don't know whether I should add additional test about it.
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.